package com.deer.wms.base.system.web.box;

import com.deer.wms.base.system.model.bill.BillOutDetailCriteria;
import com.deer.wms.base.system.model.bill.BillOutDetailDto;
import com.deer.wms.base.system.model.bill.BillOutMasterCriteria;
import com.deer.wms.base.system.model.bill.BillOutMasterDto;
import com.deer.wms.base.system.model.box.AreaBoxItem;
import com.deer.wms.base.system.model.box.AreaBoxItemDto;
import com.deer.wms.base.system.model.item.ItemInfoDto;
import com.deer.wms.base.system.model.item.ItemInfoParam;
import com.deer.wms.base.system.service.bill.IBillOutDetailService;
import com.deer.wms.base.system.service.box.AreaBoxItemService;
import com.deer.wms.common.annotation.Log;
import com.deer.wms.common.core.controller.BaseController;
import com.deer.wms.common.core.domain.AjaxResult;
import com.deer.wms.common.core.page.TableDataInfo;
import com.deer.wms.common.core.text.Convert;
import com.deer.wms.common.enums.BusinessType;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
@RequestMapping("/out/AreaBoxItem")
public class AreaBoxItemController extends BaseController {
    private String prefix = "out/AreaBoxItem";
    @Autowired
    private AreaBoxItemService areaBoxItemService;

    /**
     * 跳转页面
     * @return
     */
    @RequiresPermissions("out:AreaBoxItem:view")
    @GetMapping("/page")
    public String workMaster()
    {
        return prefix + "/AreaBoxItem";
    }

      /***
       *暂存区显示全部
       * @author 李帅辰
       * @date 2020/10/16 18:11
       * @return com.deer.wms.common.core.page.TableDataInfo
       */
        @RequiresPermissions("out:AreaBoxItem:list")
        @PostMapping("/findList")
        @ResponseBody
        public TableDataInfo findList(AreaBoxItemDto areaBoxItemDto) {
            startPage();
            List<AreaBoxItemDto> areaBoxItemList = areaBoxItemService.findAreaBoxItemList(areaBoxItemDto);
            return getDataTable(areaBoxItemList);
        }

    /**
     * 显示暂存区库存
     */
    @PostMapping("/areaBoxItemList")
    @ResponseBody
    public TableDataInfo findList()
    {
        startPage();
        List<AreaBoxItemDto> areaBoxItemList = areaBoxItemService.findListItem();
        return getDataTable(areaBoxItemList);
    }


    @PostMapping("/findListItem")
    @ResponseBody
    @Transactional
    public TableDataInfo findListItem() {
        startPage();
        List<AreaBoxItemDto> areaBoxItemList = areaBoxItemService.findListItem();
        return getDataTable(areaBoxItemList);
    }



    @PostMapping( "/insert")
    @ResponseBody
    @Transactional(rollbackFor = Exception.class)
    public AjaxResult insert(AreaBoxItem areaBoxItem){
        return toAjax(areaBoxItemService.saveAreaBoxItem(areaBoxItem));
    }
}
